<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="客户列表" name="first">
				<el-row :gutter="24">
					<el-col :span="1" style="margin-right:10px;">
						<p class="queryLabel">车牌号:</p>
					</el-col>
					<el-col :span="4">
						<el-input size="small" :maxlength="200" v-model="condition.plateNum" placeholder="请输入车牌号">
						</el-input>
					</el-col>
					<el-col :span="1" style="margin-right:10px;">
						<p class="queryLabel">车主:</p>
					</el-col>
					<el-col :span="4">
						<el-input size="small" :maxlength="200" v-model="condition.insured" placeholder="请输入车主">
						</el-input>
					</el-col>
					<el-col :span="1" style="margin-right:10px;">
						<p class="queryLabel">车龄:</p>
					</el-col>
					<el-col :span="4">
						<el-input size="small" :maxlength="200" v-model="condition.carAge" placeholder="请输入车龄">
						</el-input>
					</el-col>
					<el-col :span="1" style="margin-right:10px;">
						<p class="queryLabel">车型:</p>
					</el-col>
					<el-col :span="4">
						<el-input placeholder="请输入车型" :maxlength="200" size="small" v-model="condition.carModel">
						</el-input>
					</el-col>
				</el-row>
				<el-row :gutter="24">
					<el-col :span="1" style="margin-right:10px;">
						<p class="queryLabel">VIN:</p>
					</el-col>
					<el-col :span="4">
						<el-input placeholder="请输入VIN" :maxlength="200" size="small" v-model="condition.vin">
						</el-input>
					</el-col>
					<el-col :span="2" style="text-align:center">
						<el-button type="primary" size="small" v-on:click='companyQuery'>查询</el-button>
					</el-col>
					<el-col :span="17" style="margin-left: -10px;text-align: right">
						<el-button type="primary" size="small" v-on:click='add'>新增</el-button>
						<el-button type="primary" size="small" v-on:click='editCom'>编辑</el-button>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="24">
						<el-table :data="tableData.dataList" border style="width: 100%;align-content: center;" @selection-change="handleSelectionChange" @row-dblclick="dbClick">
							<el-table-column type="selection" width="40">
							</el-table-column>
							<el-table-column label="车牌号" prop="plateNum">
							</el-table-column>
							<el-table-column label="VIN" align="right" prop="vin">
							</el-table-column>
							<el-table-column label="车主" align="right" prop="driverLicense">
							</el-table-column>
							<el-table-column label="联系电话" align="right" prop="contactPhone">
							</el-table-column>
							<el-table-column label="车龄" align="right" prop="age">
							</el-table-column>
							<el-table-column label="车型" align="right" prop="carModel">
							</el-table-column>
							<el-table-column label="厂牌代码" align="right" prop="label">
							</el-table-column>
							<el-table-column label="操作" align="right" width="120">
								<template scope="scope">
									<el-button type="primary" size="small" @click.native.prevent="info(scope.$index)">查看保险单</el-button>
								</template>
							</el-table-column>
						</el-table>
						<el-pagination small @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="CurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="tableData.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-tab-pane>
			<el-tab-pane label="保险单" name="second">
				<el-row>
					<el-col :span="24">
						<el-table class="baoxian" :data="tableDatas.dataList" border style="width: 100%;align-content: center;" @selection-change="handleSelectionChanges">
							<el-table-column type="selection" width="40">
							</el-table-column>
							<el-table-column label="投保公司" prop="insuranceCompanyName" width="150px">
							</el-table-column>
							<el-table-column label="商业险项目" align="right" prop="syItems" width="150px">
							</el-table-column>
							<el-table-column label="商业险合同号" align="right" prop="syContractNo" width="150px">
							</el-table-column>
							<el-table-column label="商业险起止日期" align="right" prop="syStopDate" width="200px">
							</el-table-column>
							<el-table-column label="商业险金额" align="right" prop="syPrice" width="120px">
							</el-table-column>
							<el-table-column label="交强险项目" align="right" prop="jqItems" width="150px">
							</el-table-column>
							<el-table-column label="交强险合同号" align="right" prop="jqContractNo" width="150px">
							</el-table-column>
							<el-table-column label="交强险起止日期" align="right" prop="jqStopDate" width="200px">
							</el-table-column>
							<el-table-column label="交强险金额" align="right" prop="jqPrice" width="120px">
							</el-table-column>
						</el-table>
						<el-pagination small @size-change="handleSizeChanges" @current-change="handleCurrentChanges" :current-page="CurentPage" :page-sizes="page.pageSizes" :page-size="page.pageSize" layout=" total,prev, pager, next" :total="tableDatas.total">
						</el-pagination>
					</el-col>
				</el-row>
			</el-tab-pane>
		</el-tabs>
		<el-dialog title="客户档案维护" v-model="comFormShow" size="small">
			<el-form :model="comFormData" ref="comForm" :rules="Rule" label-width="150px">
				<el-row :gutter="24">
				<el-col :span="12">
					<el-form-item label="被保险人：" prop="insured">
						<el-input size="small" :maxlength="200" @change="peopleChange" v-model="comFormData.insured">
							<el-select v-model="comFormData.source" style="width: 80px;" slot="prepend">
                                            <el-option label="个人" value="0"></el-option>
                                            <el-option label="单位" value="1"></el-option>
                                        </el-select>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="被保险人证件号：" prop="insuredIdNumber">
						<el-input size="small" :maxlength="200" v-model="comFormData.insuredIdNumber"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="联系电话：" prop="contactPhone">
						<el-input size="small" :maxlength="200" v-model="comFormData.contactPhone"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车架号：" prop="vin">
						<el-input size="small" :maxlength="200" v-model="comFormData.vin"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="车型：" prop="carModel">
						<!--<el-input size="small" v-model="comFormData.carModel"></el-input>-->
						<el-input placeholder="请选择车型" :maxlength="200" size="small" icon="search" v-model="comFormData.carModel" :on-icon-click="handleIconClick">
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="初次登记日期：" required>
						<!--<el-input size="small" v-model="comFormData.firstRecordDates"></el-input>-->
						<el-date-picker size="small" style="width: 95%;" v-model="firstRecordDates" format="yyyy-MM-dd" type="date" placeholder="初次登记日期">
						</el-date-picker>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="厂牌代码：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.label"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="被保险人地址：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.insuredAddress"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="邮编：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.postCode"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="联系人：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.contactName"></el-input>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="E_mail：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.email"></el-input>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="车牌号：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.plateNum"></el-input>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="发动机号：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.engineNum"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="新车属性：">
						<el-select size="small" style="width: 100%;" v-model="comFormData.carProperty" placeholder="选择新车属性">
							<el-option label="新车金融" value="xcjr">
							</el-option>
							<el-option label="新车全款" value="xcqk">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="销售属性：">
						<el-select size="small" style="width: 100%;" v-model="comFormData.salesProperty" placeholder="选择销售属性">
							<el-option label="本地销" value="bdx">
							</el-option>
							<el-option label="外地销" value="wdx">
							</el-option>
						</el-select>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="发动机类型：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.carType"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="排量/功率：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.power"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="载客/载重量：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.passengerWeight"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="使用性质：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.useProperty"></el-input>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item label="行驶证车主：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.driverLicense"></el-input>
					</el-form-item>
				</el-col>

				<el-col :span="12">
					<el-form-item label="实际价值：" >
						<el-input size="small" :maxlength="200" v-model="comFormData.realValue"></el-input>
					</el-form-item>
				</el-col>
				</el-row>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="comFormShow = false">取 消</el-button>
				<el-button type="primary" v-on:click='save'>提 交</el-button>
			</div>
		</el-dialog>
		<!--
        	作者：1813180149@qq.com
        	时间：2017-05-03
        	描述：车型车系选择框
        -->
		<el-dialog title="选择车型" v-model="showStart" size="small">
			<el-row :gutter="24">
				<el-col :span="11" style="margin-left:5px;">
					<el-input size="small" v-model="dictTreeSearchValue" placeholder="请输入内容" icon="search" @click="searchTree"></el-input>
				</el-col>
				<el-col :span="11" style="margin-left:5px;">
					<!--<el-select size="small"
						           style="width: 100%;margin-left:15px;"
						           v-model="company"
						           placeholder="请选择品牌"
						           clearable>
							<el-option v-for="item in companyData"
							           :label="item.label"
							           :value="item.value"></el-option>
						</el-select>-->
				</el-col>
				<el-col :span="24" style="margin-left:5px;">
					<div style="height: 3em;"></div>
				</el-col>
				<el-col :span="24" style="margin-left:5px; height: 250px;overflow: scroll;">
					<el-tree :data="paramTreeData" :filter-node-method="filterNode" :highlight-current=true :props="defaultProps" accordion @node-click="handleNodeClick" :auto-expand-parent=false ref="dictTree" node-key="id"></el-tree>
				</el-col>
			</el-row>

			<div slot="footer" class="dialog-footer">
				<el-button @click="showStart = false">取 消</el-button>
				<el-button type="primary" @click="saveCarSerices">提 交</el-button>
			</div>
		</el-dialog>

		<el-dialog title="选择要搜索的车型" v-model="searchCarShow" size="small">
			<el-row :gutter="24">
				<el-col :span="11" style="margin-left:5px;">
				</el-col>
				<el-col :span="24" style="margin-left:5px;">
					<div style="height: 3em;"></div>
				</el-col>
				<el-col :span="24" style="margin-left:5px; height: 250px;overflow: scroll;">
					<el-tree :data="SearchTreeData" :filter-node-method="filterNode" :highlight-current=true :props="defaultProps" accordion @node-click="searchNodeClick" :auto-expand-parent=false node-key="id"></el-tree>
				</el-col>
			</el-row>

			<div slot="footer" class="dialog-footer">
				<el-button @click="searchCarShow = false">取 消</el-button>
				<el-button type="primary" @click="serchSaveCar">提 交</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
	import moment from 'moment'
	export default {
		data: function() {
			return {
				firstRecordDates: null, //form里面的时间
				//保险单初始分页
				CurentPages: 1,
				CurentPage: 1,
				//每页的数量
				page: this.page,
				insuranceCombo: [{
					label: '交强险',
					value: '0'
				}, {
					label: '商业险',
					value: '1'
				}],
				commissionCombo: [{
					label: '常规佣金',
					value: '0'
				}, {
					label: '促销佣金',
					value: '1'
				}],
				//页码数
				CurentPage: 1,
				//每页的数量
				page: this.page,
				//公司数据
				tableData: {
					total: 0,
					dataList: []
				},
				//佣金数据
				//分组数据
				tableDatas: {
					total: 0,
					dataList: []
				},
				activeName: 'first',
				companyName: '',
				condition: {
					plateNum: "",
					carAge: "",
					carModel: "",
					insured: "",
					carValue: '',
					carLevel: '',
					vin: '',
				},
				conditions: {
					date: "",
					companyId: ""
				},
				comFormShow: false,
				comFormShows: false,
				//校验规则
				Rule: {
					insured: [{
						required: true,
						message: '请输入被保险人',
						trigger: 'blur'
					}],
					insuredIdNumber: [{
						required: true,
						message: '请输入被保险人证件号',
						trigger: 'blur'
					}],
					insuredAddress: [{
						required: true,
						message: '请输入被保险人地址',
						trigger: 'blur'
					}],
					postCode: [{
						required: true,
						message: '请输入邮编',
						trigger: 'blur'
					}],
					contactName: [{
						required: true,
						message: '请输入联系人',
						trigger: 'blur'
					}],
					contactPhone: [{
						required: true,
						message: '请输入联系电话',
						trigger: 'blur'
					}],
					vin: [{
						required: true,
						message: '请输入车架号',
						trigger: 'blur'
					}],
					//					firstRecordDate:[{
					//						required: true,
					//						message: '请输入初次登记日期',
					//						trigger: 'blur'
					//					}],
					engineNum: [{
						required: true,
						message: '请输入发动机号',
						trigger: 'blur'
					}],
					power: [{
						required: true,
						message: '请输入排量',
						trigger: 'blur'
					}],
					email: [{
						required: true,
						message: '请输入email',
						trigger: 'blur'
					}],
					carModel: [{
						required: true,
						message: '请输入车型',
						trigger: 'blur'
					}],
					useProperty: [{
						required: true,
						message: '请输入使用性质',
						trigger: 'blur'
					}],
					driverLicense: [{
						required: true,
						message: '请输入行驶证车主',
						trigger: 'blur'
					}],
					passengerWeight: [{
						required: true,
						message: '请输入载客/载重量',
						trigger: 'blur'
					}],
				},
				//校验规则
				Rules: {},
				comFormData: {
					source:'0',//被保险人类型
					insured: "",
					compulsoryTotal: "",
					insuredIdNumber: "",
					carType: "",
					useProperty: "",
					commercialinsuranceTotal: "",
					driverLicense: "",
					vin: "",
					id: "",
					ower: "",
					email: "",
					passengerWeight: "",
					contactName: "",
					engineNum: "",
					updateUser: "",
					updateTime: "",
					firstRecordDate: null,
					plateNum: "",
					insuranceStopDate: '',
					carAge: "",
					realValue: "",
					companyId: "",
					createTime: "",
					createUser: "",
					postCode: "",
					insuredAddress: "",
					contactPhone: "",
					insuranceStartDate: "",
					carModel: "",
					carLevel: '',
					carValue: '',
					power: ""
				},
				emptyData: {
					source:'0',//被保险人类型
					insured: "",
					compulsoryTotal: "",
					insuredIdNumber: "",
					carType: "",
					useProperty: "",
					commercialinsuranceTotal: "",
					driverLicense: "",
					vin: "",
					id: "",
					ower: "",
					email: "",
					passengerWeight: "",
					contactName: "",
					engineNum: "",
					updateUser: "",
					updateTime: "",
					firstRecordDate: null,
					plateNum: "",
					insuranceStopDate: "",
					carAge: "",
					realValue: "",
					companyId: "",
					createTime: "",
					createUser: "",
					postCode: "",
					insuredAddress: "",
					contactPhone: "",
					insuranceStartDate: "",
					carModel: "",
					carLevel: '',
					carValue: '',
					power: ""
				},
				comFormDatas: {
					companyId: "",
					createTime: "",
					updateUser: "",
					createUser: "",
					update: "",
					commission: "",
					id: "",
					insuranceType: "",
					commissionType: "",
					startDate: "",
					stopDate: "",
					insuranceCompanyName: ""
				},
				emptyDatas: {
					companyId: "",
					createTime: "",
					updateUser: "",
					createUser: "",
					update: "",
					commission: "",
					id: "",
					insuranceType: "",
					commissionType: "",
					startDate: "",
					stopDate: "",
					insuranceCompanyName: ""
				},
				multipleSelection: [],
				multipleSelections: [],
				companyId: "",
				//树形图查询条件
				dictTreeSearchValue: "",
				paramTreeData: [],
				//搜索的车型数据
				SearchTreeData: [],
				//树型数据配置
				defaultProps: {
					children: 'child',
					label: 'label',
				},
				showStart: false,
				searchCarShow: false,
				//品牌
				company: "",
				//品牌
				companyData: [{
					label: '全部',
					value: 'all'
				}, {
					label: '大众',
					value: '2'
				}, {
					label: '别克',
					value: '3'
				}, ],
				//选中的类型（车型/车系）
				carType: '',
				//搜索的选中类型
				searhcarType: '',
				//选择的车辆信息
				datalabel: '',
				datavale: '',
				dataNumber:'',
				//搜索的车型
				searchcarType: '',
				searchdatalabel: '', //搜索的选择的车辆信息
				searchdatavale: '',
				searchdataNumber:'',
			}
		},
		methods: {
			//新增客户档案时被保险人 = 联系人 = 行驶证车主
			peopleChange: function() {
				this.$data.comFormData.contactName = this.$data.comFormData.insured;
				this.$data.comFormData.driverLicense = this.$data.comFormData.insured;
			},
			//查询树节点
			searchTree: function() {
				if(this.$data.dictTreeSearchValue == "") {
					debugger;
					this.$message("请输入查询条件");
					this.queryParamTree();
					return;
				}
				this.$refs.dictTree.filter(this.$data.dictTreeSearchValue);
			},
			//点击资源树节点
			handleNodeClick(data) {
				debugger;
				this.$data.comFormData.carLevel = '';
				this.$data.carType = data.type;
				this.$data.comFormData.carLevel = data.type;
				this.$data.datalabel = data.label;
				this.$data.datavale = data.value;
				this.$data.dataNumber = data.number;
			},
			//点击搜索的资源树节点
			searchNodeClick(data) {
				debugger;
				this.$data.condition.carLevel = '';
				this.$data.condition.carValue = '';

				this.$data.searhcarType = data.type;
				this.$data.searchdatalabel = data.label;
				this.$data.searchdatavale = data.value;
				this.$data.condition.carLevel = data.type;
				this.$data.condition.carValue = data.value;
			},
			//查询参数树
			queryParamTree: function() {
				//获取资源树
				debugger;
				this.$http.get(this.API_ROOT + '/base/car/pages', {
					params: {
						type: '0'
					}
				}).then((response) => {
					debugger;
					this.$data.paramTreeData = response.data;
				}, (response) => {});
			},
			//查询搜索的参数树
			querySearchTree: function() {
				//获取资源树
				debugger;
				this.$http.get(this.API_ROOT + '/base/car/tree', {}).then((response) => {
					debugger;
					this.$data.SearchTreeData = response.data;
				}, (response) => {});
			},
			//资源过滤
			filterNode: function(value, data, node) {
				if(!value) return true;
				return data.label.indexOf(value) !== -1;
			},
			//手动触发
			//			baseQuery: function() {
			//				this.$data.showStart = true;
			//
			//			},
			//确认车型
			saveCarSerices: function() {
				debugger;
				this.$data.comFormData.carModel = '';
				if(this.$data.carType == '2' || this.$data.carType == '1') {
					this.$data.comFormData.carModel = this.$data.datalabel;
					this.$data.comFormData.carValue = this.$data.datavale;
					this.$data.comFormData.label = this.$data.dataNumber;
				} else {
					this.$message("未选中车型");
				}
				this.$data.showStart = false;
			},
			//搜索确认车型
			serchSaveCar: function() {
				debugger;
				this.$data.condition.carModel = '';
				if(this.$data.searhcarType == '2') {
					this.$data.condition.carModel = this.$data.searchdatalabel;
				} else {
					this.$message("未选中车型");
				}
				this.$data.searchCarShow = false;
			},
			//打开车型车系选择
			handleIconClick: function() {
				this.$data.showStart = true;
			},
			//打开搜索的车型选择
			chooseSearchModel: function() {
				this.$data.searchCarShow = true;
			},
			//状态转换
			statusCov: function(row, column) {
				return row.status == "1" ? '已启用' : '已停用';
			},
			//保险类别转换
			//状态转换
			insCov: function(row, column) {
				return row.insuranceType == "1" ? '商业险' : '交强险';
			},
			//状态转换
			commCov: function(row, column) {
				return row.commissionType == "1" ? '促销佣金' : '常规佣金';
			},
			//佣金类别转换

			//选择框
			handleSelectionChange: function(val) {
				debugger;
				this.$data.multipleSelection = val;
			},
			//选择框
			handleSelectionChanges: function(val) {
				debugger;
				this.$data.multipleSelections = val;
			},
			//切换tab页
			handleClick: function(tab, event) {
				console.log(tab, event);
			},
			add: function() {
				this.$data.comFormData = Object.assign(this.$data.comFormData, this.$data.emptyData);
				this.$data.firstRecordDates = null;
				this.$data.comFormShow = true;
			},
			addCommission: function() {

				this.$data.comFormDatas = Object.assign(this.$data.comFormDatas, this.$data.emptyDatas);
				this.$data.comFormDatas.companyId = this.$data.conditions.companyId
				this.$data.comFormShows = true;
			},

			//编辑客户档案
			editCom: function() {
				if(this.$data.multipleSelection.length == 1) {
					var resRoleData = this.$data.multipleSelection[0];
					this.$http.get(this.API_ROOT + '/insurance/car/carInfo', {
						params: {
							id: this.$data.multipleSelection[0].id
						}
					}).then((response) => {
						debugger;
						this.$data.comFormData = Object.assign(this.$data.comFormData, response.data.data);
						this.$data.firstRecordDates = response.data.data.firstRecordDate;
						this.companyQuery();
					}, (response) => {
						// error callback
					});
					this.$data.comFormShow = true;
				} else {
					this.$message.error("请选择一条数据");
				}
			},
			//查询客户档案列表
			companyQuery: function() {
				this.$http.post(this.API_ROOT + '/insurance/car/page', this.$data.condition, {
					params: {
						start: this.$data.CurentPage,
						limit: this.page.pageSize
					}
				}).then(resp => {
					if(resp.data.success) {
						resp.data.total = parseInt(resp.data.total);
						// es5写法
						this.$data.tableData = resp.data;
						//this.baseQuery(this.$data.curTreeDeptId);
						//this.$data.exFormShow = false;
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//查询保险单
			orderQuery: function() {
				debugger;
				this.$http.get(this.API_ROOT + '/insurance/Order/hasOrder', {
					params: {
						carId: this.$data.conditions.companyId,
						start: this.$data.CurentPages,
						limit: this.page.pageSize
					}
				}).then(resp => {
					if(resp.data.success) {
						debugger;
						resp.data.total = parseInt(resp.data.total); // es5写法
						this.$data.tableDatas = resp.data;
						for(var i = 0; i < this.$data.tableDatas.dataList.length; i++) {
							if(this.$data.tableDatas.dataList[i].syStopDate){
								this.$data.tableDatas.dataList[i].syStopDate = this.$data.tableDatas.dataList[i].syStartDate + "/" + this.$data.tableDatas.dataList[i].syStopDate;
							}else{
								this.$data.tableDatas.dataList[i].syStopDate = "";
							};
							if(this.$data.tableDatas.dataList[i].jqStopDate){
								this.$data.tableDatas.dataList[i].jqStopDate = this.$data.tableDatas.dataList[i].jqStartDate + "/" + this.$data.tableDatas.dataList[i].jqStopDate;
							}else{
								this.$data.tableDatas.dataList[i].jqStopDate = ""
							}
							
							

						}
						//this.baseQuery(this.$data.curTreeDeptId);
						//this.$data.exFormShow = false;
					} else {
						//debugger;
						this.$message.error(resp.data.msg);
					}
				}, resp => {});
			},
			//查看保险单
			info: function(index) {
				this.$data.conditions.companyId = this.$data.tableData.dataList[index].id;
				debugger;
				this.orderQuery();
				this.$data.activeName = "second";
			},
			//保存
			save: function() {
				debugger;
				if(this.$data.comFormData.source == '0' && this.isCardNo(this.$data.comFormData.insuredIdNumber) == false) {
					this.$message.error("请填写正确的身份证号");
				} else if(this.$data.comFormData.vin.length != 17) {
					this.$message.error("请填写正确的车架号");
				} else if(this.$data.comFormData.plateNum == '') {
					this.$confirm('确定不填写车牌号吗?', '提示', { //出单询问
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					}).then(() => {
						this.$refs.comForm.validate(function(valid, $event) {
							// 验证通过
							if(valid) {
								debugger;

								this.$data.comFormData.firstRecordDate = this.momentFu(this.$data.firstRecordDates);
								if(this.$data.comFormData.firstRecordDate == null) {
									this.$message.error("请选择初次登记日期");
									return false;
								}
								if(this.$data.comFormData.firstRecordDate) {
									this.$http.post(this.API_ROOT + '/insurance/car/save', this.$data.comFormData)
										.then(resp => {
											if(resp.data.success) {
												debugger;
												this.companyQuery();
												this.$data.comFormShow = false;
												this.$message(resp.data.msg);
											} else {
												this.$message.error(resp.data.msg);
											}
										}, resp => {

										});
								}
							} else {
								return false
							}
						}.bind(this))
					}).catch(() => {
						this.$message({
							type: 'info',
							message: '取消'
						});
					});
				} else {
					this.$refs.comForm.validate(function(valid, $event) {
						// 验证通过
						if(valid) {
							debugger;
							this.$data.comFormData.firstRecordDate = this.momentFu(this.$data.firstRecordDates);
							if(this.$data.comFormData.firstRecordDate == null) {
								this.$message.error("请选择初次登记日期");
								return false;
							}
							if(this.$data.comFormData.firstRecordDate) {
								this.$http.post(this.API_ROOT + '/insurance/car/save', this.$data.comFormData)
									.then(resp => {
										if(resp.data.success) {
											debugger;
											this.companyQuery();
											this.$data.comFormShow = false;
											this.$message(resp.data.msg);
										} else {
											this.$message.error(resp.data.msg);
										}
									}, resp => {

									});
							}
						} else {
							return false
						}
					}.bind(this))
				}
			},
			//身份验证
			isCardNo: function(card) {
				debugger;
				// 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X  
				var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				if(reg.test(card) === false) {
					return false;
				} else {
					return true;
				}
			},
			//时间判断为空的封装
			momentFu: function(dt) {
				debugger;
				if(dt == '' || dt == null || dt == undefined) {
					this.$message.error("请选择初次登记日期");
					return "";
				} else {
					return this.moment(dt).format("YYYY-MM-DD");
				}
			},
			//列表，分页大小切换
			handleSizeChange: function() {},
			//保险单列表分页
			handleSizeChanges: function() {},
			//保险单列表分页切换
			handleCurrentChanges: function(currentPages) {
				this.$data.currentPages = currentPages;
				this.info();
			},
			//列表,当前页切换
			handleCurrentChange: function(currentPage) {
				debugger;
				this.$data.CurentPage = currentPage;
				//this.$data.dictGroup = '';
				this.companyQuery();
			},
			//表格双击事件
			dbClick: function(row, event) {
				this.$http.get(this.API_ROOT + '/insurance/car/carInfo', {
					params: {
						id: row.id
					}
				}).then((response) => {
					debugger;
					this.$data.comFormData = Object.assign(this.$data.comFormData, response.data.data);
					this.$data.firstRecordDates = response.data.data.firstRecordDate;
					if(this.$data.comFormData.source == "" || this.$data.comFormData == null){
						this.$data.comFormData.source = 0;
					}
					//this.companyQuery();
				}, (response) => {
					// error callback
				});
				this.$data.comFormShow = true;
			},
		},
		//表单创建时执行
		created: function() {
			this.companyQuery();
			this.queryParamTree();
		}
	}
</script>
<style>
	.el-table .info-row {
		height: 10px !important;
	}
	
	.item {
		width: 30px;
	}
	
	.el-form-item {
		clear: both;
	}
	
	.el-dropdown .el-button-group,
	.el-table .el-tooltip,
	.el-table .el-tooltip__rel {
		display: inline;
	}
	
	.el-table {
		height: 100%;
		width: 100%;
	}
	
	.baoxian {
		white-space: normal !important;
	}
	
	#el-select {
		width: 200px;
	}
</style>